package com.third.customer.service.data;

import com.third.customer.model.data.UserType;
import com.third.customer.service.exception.ThirdBadRequestException;
import lombok.Data;

import javax.validation.constraints.NotEmpty;

/**
 * Created by hehuaichun on 2020/5/19.
 */
@Data
public class UserReq {

    @NotEmpty
    private String name;

    private UserType type = UserType.ORDINARY;
    //todo 之后加密
    @NotEmpty
    private String password;

    public void validator(){
        //todo 检查密码是否有特殊字符
        if(name.length() > 10){
            throw new ThirdBadRequestException("名字长度过长!");
        }
        if(password.length() > 20){
            throw new ThirdBadRequestException("密码长度过长!");
        }
    }

}
